
<?php
$x=5;
$y=10;

$z=$x+$y;
echo $z;
// echo "</br>";
function myTest()
{
	/**
	 * global关键字
	 */
global $x,$y;
$y=$x+$y;
}

myTest();
echo "  x+y=",$y; // 输出 15
// echo "<br>";
function myTest1()
{
$GLOBALS['y']=$GLOBALS['x']+$GLOBALS['y'];
} 

myTest1();
echo "  x+y=",$y;

$f=5;

function myTest2()
{
	$y=10; // 局部变量 
    echo "<p>测试函数内变量:<p>"; 
    echo "变量 f 为: $f"; 
    echo "<br>"; 
    echo "变量 y 为: $y";

}
myTest2(); 

echo "<p>测试函数外变量:<p>"; 
echo "变量 f 为: $f"; 
echo "<br>"; 
echo "变量 y 为: $y"; 

function myTest3() 
{ 
    static $x=0; 
    echo "  ",$x; 
    $x++; 
} 

myTest3(); 
myTest3(); 
myTest3();


?>
